package com.mdd.admin.controller.yylq;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.yylq.ITAppEnterpriseQualificationService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.validate.yylq.TAppEnterpriseQualificationCreateValidate;
import com.mdd.admin.validate.yylq.TAppEnterpriseQualificationSearchValidate;
import com.mdd.admin.validate.yylq.TAppEnterpriseQualificationUpdateValidate;
import com.mdd.admin.vo.yylq.TAppEnterpriseQualificationDetailVo;
import com.mdd.admin.vo.yylq.TAppEnterpriseQualificationListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/adminapi/yylq/qualification")
@Api(tags = "羊羊领企---领企管家----企业资质管理")
public class TAppEnterpriseQualificationController {

    @Resource
    ITAppEnterpriseQualificationService iTAppEnterpriseQualificationService;

    @GetMapping("/list")
    @ApiOperation(value="领企管家----企业资质列表")
    public AjaxResult<PageResult<TAppEnterpriseQualificationListedVo>> list(@Validated PageValidate pageValidate,
                                                     @Validated TAppEnterpriseQualificationSearchValidate searchValidate) {
        PageResult<TAppEnterpriseQualificationListedVo> list = iTAppEnterpriseQualificationService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="领企管家----企业资质详情")
    public AjaxResult<TAppEnterpriseQualificationDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        TAppEnterpriseQualificationDetailVo detail = iTAppEnterpriseQualificationService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "领企管家----企业资质新增")
    @PostMapping("/add")
    @ApiOperation(value="领企管家----企业资质新增")
    public AjaxResult<Object> add(@Validated @RequestBody TAppEnterpriseQualificationCreateValidate createValidate) {
        iTAppEnterpriseQualificationService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "领企管家----企业资质编辑")
    @PostMapping("/edit")
    @ApiOperation(value="领企管家----企业资质编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody TAppEnterpriseQualificationUpdateValidate updateValidate) {
        iTAppEnterpriseQualificationService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "领企管家----企业资质删除")
    @PostMapping("/del")
    @ApiOperation(value="领企管家----企业资质删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iTAppEnterpriseQualificationService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
